package main

import (
	"archive/zip"
	"bytes"
	"compress/flate"
	"io"
)

func main() {
	//RegisterCompressor 注册或覆盖特定方法 ID 的自定义压缩器。 如果未找到给定方法的压缩器，Writer 将默认在包级别查找压缩器。

	buf := new(bytes.Buffer)

	// Create a new zip archive.
	w := zip.NewWriter(buf)

	// Register a custom Deflate compressor.
	w.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
		return flate.NewWriter(out, flate.BestCompression)
	})
	// Proceed to add files to w.
}
